<?php
	$this->headScript()->appendFile($this->dirJs.'/msdropdown/msdropdown/jquery.dd.js');
	$this->headLink()->appendStylesheet($this->dirJs.'/msdropdown/msdropdown/dd.css');
	$this->headLink()->appendStylesheet($this->dirCss.'/mainstyle.css');

	$this->headScript()->appendFile($this->dirJs.'/jdpicker/jquery.jdpicker.js');
	$this->headLink()->appendStylesheet($this->dirJs.'/jdpicker/jdpicker.css');
?>
<?php echo $this->render('common/header.phtml'); ?>

	<div id="main-content-wrapper">
	
		<div id="main-content">
		
		<form id="cominfoform" name="cominfo-form" method="post" action="">
        <?php 
			//Zend_Debug::dump($this->error_code);
			
			if(!empty($this->error_code)){
				echo '<span class="top-error" >Sorry, there are errors with the information you provided! Please scroll down to check for errors.</span>';	
			}
		?>
			<div id="company-infomation">	
            	<div id="com-info-title">			
					<p class="com-title">COMPANY INFORMATION</p>
                </div><!-- END #com-info-title -->

                <div id="cominfo-content">
                    <div id="logo">
                        <div style="line-height: 196px;">
                            <img alt="logo" style="vertical-align:middle" id="uploadedimage" src="<?php echo $this->baseUrl('/public/uploads/cache/data/no_image-100x100.jpg');?>" border="0"/>
                        </div>
                        <p>
                        	<a href="javascript:"  class="uploadimage" field="uploadimage" thumb="thumbimage" preview="uploadedimage">CHANGE LOGO</a>
                            <input type="hidden" name="logo" id="thumbimage" value=""/>
    						<input type="hidden" name="logoOld" id="uploadimage" value="no_image-100x100.jpg"/>
                        </p>
                        ( <a href="javascript:">Display</a> | <a href="javascript:">Undisplay</a> )
                    </div><!-- END #logo -->
                    
                    
                    <div id="cominfo-form">	
                        <label class="cominfo-left" for="company-name">Company name</label>
                        <div class="cominfo-right">
                            <input type="text" name="company-name" id="company-name" value="<?php 	if(isset($this->formData['company-name']))
                                                                                                        echo $this->formData['company-name'];
                                                                                                    else 
                                                                                                        echo @$this->employerInfo[0]['companyname']; ?>"/>
                            <?php
                            if(!empty($this->error_code['company-name']))							
                                echo "<br/><label class='crj-top-error'>".$this->error_code['company-name']."</label>";
                            ?>
                        </div>
                        <div class="clear_row"></div>
                        
                        <label class="cominfo-left">Size</label>
                        <div class="cominfo-right">
                            <select name="companysize" width="50px">
                            <?php foreach($this->com_size as $oneSize){
                                if($this->formData['companysize'] != $oneSize['id']){
                            ?>
                                <option value="<?php echo $oneSize['id'];?>"><?php echo $oneSize['name'];?></option>
                            <?php }else{?>
                                <option selected="selected" value="<?php echo $oneSize['id'];?>"><?php echo $oneSize['name'];?></option>
                            <?php }}?>
                            </select>
                            <?php
                                if(!empty($this->error_code['companysize']))
                                    echo "<label class='crj-top-error'>".$this->error_code['companysize']."</label>";
                            ?>
                        </div>
                        
                        <div class="clear_row"></div>
                        
                        <label class="cominfo-left" for="address">Company address</label>
                        <div class="cominfo-right" >
                            <input type="text" name="companyaddress" id="companyaddress" value="<?php 	
                                                                                                    if(isset($this->formData['companyaddress']))
                                                                                                        echo $this->formData['companyaddress'];
                                                                                                    else 
                                                                                                        echo @$this->employerInfo[0]['companyaddress']; ?>"/>
                            <?php
                                if(!empty($this->error_code['companyaddress']))
                                    echo "<br/><label class='crj-top-error'>".$this->error_code['companyaddress']."</label>";
                            ?>
                        </div>
                        <div class="clear_row"></div>
                        
                        <label class="cominfo-left" for="profile">Company profile</label>
                        <div class="cominfo-right">
                            <textarea name="companyprofile" rows="10" cols="50"><?php 	
                                                                                    if(isset($this->formData['companyprofile']))
                                                                                        echo $this->formData['companyprofile'];
                                                                                    else 
                                                                                        echo @$this->employerInfo[0]['companyprofile']; ?></textarea>
                            <?php
                                if(!empty($this->error_code['companyprofile']))
                                    echo "<br/><label class='crj-top-error'>".$this->error_code['companyprofile']."</label>";
                            ?>
                        </div>
                        <div class="clear_row"></div>
                    </div><!-- END cominfo-form -->
                </div><!-- END #cominfo-content-->
			</div><!--  End #company-infomation -->
			
			
            <div id="job-info">
				<p>JOB INFORMATION</p>
				
				<label class="job-label" for="job-title">Job Title</label>
				<div class="cominfo-right">
					<input type="text" name="job[title]" value="<?php if(isset($this->formData['job']['title']))
																		echo $this->formData['job']['title']; ?>"/>
					<?php
							if(!empty($this->error_code['job']['title']))
								echo "<br/><label class='crj-error'>".$this->error_code['job']['title']."</label>";
						?>
				</div>
				<div class="clear_row"></div>
				
				<label class="job-label">Job Level</label>
				<div class="job-input">
					<select name="job[job_level_id]" id="job_level_id">
						<?php foreach($this->job_level as $oneLevel){
							if($this->formData['job']['job_level_id'] != $oneLevel['id']){
						?>
							<option value="<?php echo $oneLevel['id'];?>"><?php echo $oneLevel['name'];?></option>
						<?php }else{?>
							<option selected="selected" value="<?php echo $oneLevel['id'];?>"><?php echo $oneLevel['name'];?></option>
						<?php }}?>
					</select>
					
					<?php
						echo @$this->error_code['job-level'];
					?>
				</div>
				<div class="clear_row"></div>
				
				<label class="job-label" for="job-salary">Salary</label>
				<div class="job-input">
					<select name="job[salary_range_id]" id="salary">
						<?php foreach($this->salary_range as $oneSalary){
							if($this->formData['job']['salary_range_id'] != $oneSalary['id']){
						?>
							<option value="<?php echo $oneSalary['id'];?>"><?php echo $oneSalary['name'];?></option>
						<?php }else{?>
							<option selected="selected" value="<?php echo $oneSalary['id'];?>"><?php echo $oneSalary['name'];?></option>
						<?php }}?>
					</select>
				</div>
				<div class="clear_row"></div>
                
                <label class="job-label" for="job-salary"></label>
				<div class="job-input job-input-salary" style="margin-bottom:10px; display:none">
					From <input type="text" name="salaryfrom" />
					To <input type="text" name="salaryto" /> (USD/month)
				</div>
				<div class="clear_row"></div>
                
                
				<label class="job-label" for="job-workplace">Work place	</label>
				<div class="cominfo-right">
					<select name="job[province_id]">						
						<?php foreach($this->province as $oneProvince){
							if($this->formData['job']['province_id'] != $oneProvince['id']){
						?>
							<option value="<?php echo $oneProvince['id'];?>"><?php echo $oneProvince['name'];?></option>
						<?php }else{?>
							<option selected="selected" value="<?php echo $oneProvince['id'];?>"><?php echo $oneProvince['name'];?></option>
						<?php }}?>
					</select>
				</div>
<!-- 			<input class="job-input" type="text" name="job[province_id]" id="job-workplace" />  -->
				<div class="clear_row"></div>
				
				<label class="job-label" for="job-category">Job Category</label>
				<div class="cominfo-right">
					<select name="job[job_category_id]">
						<?php foreach($this->job_category as $oneCategory){
							if(isset($this->formData['job']['job_category_id']) && ($this->formData['job']['job_category_id'] != $oneCategory['id'])){
						?>
							<option value="<?php echo $oneCategory['id'];?>"><?php echo $oneCategory['name'];?></option>
						<?php }else{?>
							<option selected="selected" value="<?php echo $oneCategory['id'];?>"><?php echo $oneCategory['name'];?></option>
						<?php }}?>
					</select>
				</div>
<!-- 				<input class="cominfo-right" class="job-input" type="text" name="job[job_category_id]" id="job-category" /> -->
				<div class="clear_row"></div>
				
				<label class="job-label" for="job-category">Job Type</label>
				<div class="cominfo-right" style="margin-top:5px;">
					<select name="job[job_type_id]">
						<?php foreach($this->job_type as $oneType){
							if(isset($this->formData['job']['job_type_id']) && ($this->formData['job']['job_type_id'] != $oneType['id'])){
						?>
							<option value="<?php echo $oneType['id'];?>"><?php echo $oneType['name'];?></option>
						<?php }else{?>
							<option selected="selected" value="<?php echo $oneType['id'];?>"><?php echo $oneType['name'];?></option>
						<?php }}?>
					</select>
				</div>
<!-- 				<input class="cominfo-right" class="job-input" type="text" name="job[job_category_id]" id="job-category" /> -->
				<div class="clear_row"></div>
				
				<label class="job-label">Job Description</label>
				<div class="cominfo-right">
                	<textarea  name="job[description]" rows="10" cols="50"><?php echo @$this->formData['job']['description']; ?></textarea>
                    <?php
						if(!empty($this->error_code['job']['description']))							
							echo "<br/><label class='crj-error'>".$this->error_code['job']['description']."</label>";
					?>
                </div>
				<div class="clear_row"></div>
				
				<label class="job-label">Job Requirement</label>
				<div class="cominfo-right">
                	<textarea name="job[requirement]" id="job-requirement" rows="10" cols="50"><?php echo @$this->formData['job']['requirement']; ?></textarea>
                 	<?php
						if(!empty($this->error_code['job']['requirement']))							
							echo "<br/><label class='crj-error'>".$this->error_code['job']['requirement']."</label>";
					?>
                </div>
				<div class="clear_row"></div>
				
           
				<label class="job-label">Deadline</label>
				<div style="float:left">
					<input class="job-input" type="text" name="job[deadline]" id="job-deadline" value="<?php if(isset($this->formData['job']['deadline'])) echo $this->formData['job']['deadline']; else echo 'dd/mm/yyyy'; ?>" onfocus="focus(this,'dd/mm/yyyy');" onblur="blur(this,'dd/mm/yyyy');"/>
				</div>
				<div class="clear_row"></div>
				
				<label class="job-label-language" for="job-language">Prefered Language For Applications</label>
				<div class="job-input">
					<select name="job[language_require_cv_id]">
						<?php echo $this->cv_lang_list; ?>
					</select>
					<?php
						if(!empty($this->error_code['job']['language_require_cv_id']))							
							echo "<label class='crj-error'> Please choose which language you want for cv </label>";
					?>
				</div>
				<div class="clear_row"></div>
				
				<label class="job-label-language">Allow Online interview?</label>
				<div class="job-input">
					<input type="checkbox" name="" id="interview-online" />
				</div>
				<div class="clear_row" style="margin-bottom:20px;"></div>
			</div><!-- END #job-info -->
			
			<div id="contact-info">
				<p>CONTACT INFORMATION</p>
				<div class="clear_row"></div>
				<label>Contact person</label>
                
				<input type="text" name="job[contact_person_name]" id="contact-person"  value="<?php echo @$_POST['job']['contact_person_name'] ?>"/>
                <?php
                	if(isset($this->error_code['job']['contact_person_name'])){
						echo '<br/><label class="crj-error">Contact can not be empty!</label>';
					}
				?>
				<div class="clear_row"></div>
				
				<label for="email">Email for applications</label>
				<input type="text" name="job[email_for_application]" id="email" value="<?php 
																							if(isset($this->formData['job']['email_for_application'])) 
																								echo $this->formData['job']['email_for_application'];
																							else 
																								echo @$this->employerInfo[0]['email']; ?>"/>
				 <?php
                	if(isset($this->error_code['job']['email_for_application'])){
						echo '<br/><label class="crj-error">'.$this->error_code['job']['email_for_application'].'</label>';
					}
				?>
			</div><!--  END #contact-info -->
			
			<div id="bottom-contact-information">
				<a href="javascript:" id="continue-btn"><img src="<?php echo $this->baseUrl('/public/images/continue-btn.png'); ?>" alt="" /></a>
				<a href="javascript:" id="cancel"><img src="<?php echo $this->baseUrl('/public/images/cancel_btn.png'); ?>" alt="" /></a>
			</div>
			</form>
		</div><!--  END #main-content -->
    </div><!-- END # -->
    
    <?php 
	    $current = getdate();
	    $current_date = $current['mday'].'/'.$current['mon'].'/'.$current['year'];
    ?>
    
<script type="text/javascript">
	var contextPath = '<?php echo $this->baseUrl('/');?>';
	$(document).ready(function(){
		$('.uploadimage').click(function() {
		  field = $(this).attr('field');
		  thumb = $(this).attr('thumb');
		  preview = $(this).attr('preview');
		  window.open(contextPath+'employer/uploader/index/field/'+field+'/preview/'+preview+'/thumb/'+thumb, 'File manager','width=1009,height=550, directories=no, location=no,  menubar=no, resizable=no, scrollbars=0, status=no, toolbar=no return false;');
		 });
		
		$('select').msDropDown({mainCSS:'dd3'});
		$('#continue-btn').click(function(){
			$('#cominfoform').submit();
		});
	
		$('#job-deadline').jdPicker({
			date_format:"dd/mm/YYYY",
			date_min: <?php echo '"'.$current_date.'"'; ?>
		});	
		
		$('#salary').change(function(){
			var index = $(this).val();
			if(index == 3){
				$('.job-input-salary').css('display','block');
				$('.job-input-salary input').css('display','inline');
			}
			else{
				$('.job-input-salary').css('display','none');
				$('.job-input-salary input').css('display','none');
			}
		});
	});
	function focus(obj,value){
		if(obj.value == value){
			obj.value="";
		}
		
	}

	function blur(obj,value){
		if(obj.value == ""){
			obj.value = value;
		}
	}
</script>
<?php echo $this->render('common/footer.phtml'); ?>